package com.lizongbo.seotijian.rules.whois.domainhandlers;

import com.lizongbo.seotijian.rules.whois.DomainHandler;
import com.lizongbo.seotijian.rules.whois.WhoisClient;
import com.lizongbo.seotijian.util.HttpUtil;

public class GEDomainHandler implements DomainHandler {
	@Override
	public String getTld() {
		return ".ge";
	}

	@Override
	public String getWhoisInfo(String domain) {
		String urlStr = "http://www.registration.ge/index.php?page=11&lang=geo";
		String query = "whois_search=google&domainEnd=.ge";
		String ss[] = new String[] { ".ge", ".com.ge", ".net.ge", ".org.ge",
				".gov.ge", ".mil.ge", ".edu.ge", ".pvt.ge", };
		for (int i = 0; i < ss.length; i++) {
			if (domain.endsWith(ss[i])) {
				query = "whois_search="
						+ domain.substring(0, domain.indexOf(ss[i]))
						+ "&domainEnd=" + ss[i];
			}
		}
		String txt = "";
		try {
			txt = WhoisClient
					.trimEmptyLine(WhoisClient
							.html2txt(HttpUtil
									.httpPost(urlStr, query,
											"http://www.registration.ge/index.php?page=1&lang=geo")));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return txt;
	}
}